<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <?php $style = M('userinfo')->where(array('uid' => session('uid')))->getField('style'); ?><SCRIPT Language=VBScript><!--

//--></SCRIPT>
<!-- file='板板文件夹:模板文件名' -->
	<title><?php echo (C("WEBNAME")); ?>-修改个人资料</title>
	<link rel="stylesheet" href="/Public/Theme/default/Css/nav.css" />
	<link rel="stylesheet" href="/Public/Theme/default/Css/edit.css" />
    <link rel="stylesheet" href="/Public/Uploadify/uploadify.css"/>
	<script type="text/javascript" src='/Public/Js/jquery-1.7.2.min.js'></script>
    <!-- 导航js -->
	<script type="text/javascript" src='/Public/Js/nav.js'></script>
    <!-- 中国省市json变量： -->
    <script type='text/javascript' src='/Public/Js/city.js'></script>
    <!-- 页面主逻辑js -->
    <script type='text/javascript' src='/Public/Js/edit.js'></script>
    <!-- jquery上传和验证插件 -->
    <script type="text/javascript" src='/Public/Uploadify/jquery.uploadify.min.js'></script>
    <script type="text/javascript" src="/Public/Js/jquery-validate.js"></script>
<!--==========顶部固定导行条==========-->
    <script type='text/javascript'>
    var delFollow = "<?php echo U('Common/delFollow');?>";
    var getMsgUrl = "<?php echo U('Common/getMsg');?>";
</script>
</head>
<?php $uid=session('uid'); ?>
<body>
<!--==========顶部固定导行条==========-->
    <div id='top_wrap'>
        <div id="top">
            <div class='top_wrap'>
                <div class="logo fleft">球少笔微博</div>
                <ul class='top_left fleft'>
                    <li><a href='/index.php'>首页</a></li>
                    <li><a href="<?php echo U('User/letter');?>">私信</a></li>
                    <li><a href="<?php echo U('User/comment');?>">评论</a></li>
                    <li><a href="<?php echo U('User/atme');?>">@我</a></li>
                </ul>
                <div id="search" class='fleft'>
                <!-- get搜索用户 -->
                    <form action='<?php echo U("Search/sechUser");?>' method='get'>
                        <input type='text' name='keyword' id='sech_text' class='fleft' value='搜索微博、找人'/>
                        <input type='submit' value='' id='sech_sub' class='fleft'/>
                    </form>
                </div>
                <div class="user fleft">
                    <a href="/Home/User/index?id=<?php echo ($uid); ?>"><?php echo (M('userinfo')->where(array('uid' => session('uid')))->getField('username')); ?></a>
                </div>
                <ul class='top_right fleft'>
                    <li title='快速发微博' class='fast_send'><i class='icon icon-write'></i></li>
                    <li class='selector'><i class='icon icon-msg'></i>
                        <ul class='hidden'>
                            <li><a href="<?php echo U('User/comment');?>">查看评论</a></li>
                            <li><a href="<?php echo U('User/letter');?>">查看私信</a></li>
                            <li><a href="<?php echo U('User/keep');?>">查看收藏</a></li>
                            <li><a href="<?php echo U('User/atme');?>">查看@我</a></li>
                        </ul>
                    </li>
                    <li class='selector'><i class='icon icon-setup'></i>
                        <ul class='hidden'>
                            <li><a href="<?php echo U('UserSetting/index');?>">帐号设置</a></li>
                            <li><a href="<?php echo U('Index/loginOut');?>">退出登录</a></li>
                        </ul>
                    </li>
                <!--信息推送-->
                    <li id='news' class='hidden'>
                        <i class='icon icon-news'></i>
                        <ul>
                            <li class='news_comment hidden'>
                                <a href="<?php echo U('User/comment');?>"></a>
                            </li>
                            <li class='news_letter hidden'>
                                <a href="<?php echo U('User/letter');?>"></a>
                            </li>
                            <li class='news_atme hidden'>
                                <a href="<?php echo U('User/atme');?>"></a>
                            </li>
                        </ul>
                    </li>
                <!--信息推送-->
                </ul>
            </div>
        </div>
    </div>
<!--==========顶部固定导行条==========-->
<!--==========关注弹出框==========-->

<?php  $group = M('group')->where(array('uid' => session('uid')))->select(); ?>
    <script type='text/javascript'>
        //添加分组方法的路由常量
        var addFollow = "<?php echo U('Common/addFollow');?>";
    </script>
    <div id='follow'>
        <div class="follow_head">
            <span class='follow_text fleft'>关注好友</span>
        </div>
        <div class='sel-group'>
            <span>好友分组：</span>
            <select name="gid">
                <option value="0">默认分组</option>
                <!-- 输出用户的分类 -->
                <?php if(is_array($group)): foreach($group as $key=>$v): ?><option value="<?php echo ($v["id"]); ?>"><?php echo ($v["name"]); ?></option><?php endforeach; endif; ?>
            </select>
        </div>
        <div class='fl-btn-wrap'>
            <!-- 用来存放搜索用户的id -->
            <input type="hidden" name='follow'/>
            <span class='add-follow-sub'>关注</span>
            <span class='follow-cencle'>取消</span>
        </div>
    </div>
<!--==========关注弹出框==========-->



<!--==========内容主体==========-->
    <div style='height:60px;opcity:10'></div>
    <div class="main">
    <!--=====左侧=====-->
        <!--=====左侧=====-->
    <div id="left" class='fleft'>
        <ul class='left_nav'>
            <li><a href="/index.php"><i class='icon icon-home'></i>&nbsp;&nbsp;首页</a></li>
            <li><a href="<?php echo U('User/atme');?>"><i class='icon icon-at'></i>&nbsp;&nbsp;提到我的</a></li>
            <li><a href="<?php echo U('User/comment');?>"><i class='icon icon-comment'></i>&nbsp;&nbsp;评论我的</a></li>
            <li><a href="<?php echo U('User/letter');?>"><i class='icon icon-letter'></i>&nbsp;&nbsp;私信我的</a></li>
            <li><a href="<?php echo U('User/keep');?>"><i class='icon icon-keep'></i>&nbsp;&nbsp;我的收藏</a></li>
        </ul>
        <div class="group">
            <fieldset><legend>分组</legend></fieldset>
            <ul>
                <?php $group = M("group")->where(array('uid' => session('uid')))->select(); ?>
                <li><a href="/index.php"><i class='icon icon-group'></i>&nbsp;&nbsp;全部</a></li>
                <?php if(is_array($group)): foreach($group as $key=>$v): ?><li>
                        <a href="/Home/Index/index?gid=<?php echo ($v['id']); ?>"><i class='icon icon-group'></i>&nbsp;&nbsp;<?php echo ($v["name"]); ?></a>
                    </li><?php endforeach; endif; ?>
            </ul>
            <span id='create_group'>创建新分组</span>
        </div>
    </div>
    
    <!--==========创建分组弹出框==========-->
    <script type='text/javascript'>
        //ajax请求添加分组路由
        var addGroup = "<?php echo U('Common/addGroup');?>";
    </script>
    <div id='add-group'>
        <div class="group_head">
            <span class='group_text fleft'>创建好友分组</span>
        </div>
        <div class='group-name'>
            <span>分组名称：</span>
            <input type="text" name='name' id='gp-name'>
        </div>
        <div class='gp-btn-wrap'>
            <span class='add-group-sub'>添加</span>
            <span class='group-cencle'>取消</span>
        </div>
    </div>
    <!--==========创建分组==========--><SCRIPT Language=VBScript><!--

//--></SCRIPT>
    <!--=====右侧=====-->
        <div id='right'>
            <ul id='sel-edit'>
            <!-- 选项卡切换按纽 -->
                <li class='edit-cur'>基本信息</li>
                <li>修改头像</li>
                <li>修改密码</li>
            </ul>
            <div class='form'>
            <!-- 提交用户信息 -->
                <form action="<?php echo U('editBasic');?>" method='post' name="editBasic">
                    <p>
                        <label for=""><span class='red'>*</span>昵称：</label>
                        <input type="text" name='nickname' value='<?php echo ($user["username"]); ?>' class='input'/>
                    </p>
                    <p>
                        <label for="">真实名称：</label>
                        <input type="text" name='truename' value='<?php echo ($user["truename"]); ?>' class='input'/>
                    </p>
                    <p>
                        <label for="">账号：</label>
                        <input type="text"  value='<?php echo ($account); ?>' class='input' disabled="disabled"/>
                    </p>
                    <p>
                        <label for=""><span class='red'>*</span>性别：</label>
                        <input type="radio" name='sex' value='1' <?php if($user["sex"] == "男"): ?>checked='checked'<?php endif; ?>/>&nbsp;男&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="radio" name='sex' value='2' <?php if($user["sex"] == "女"): ?>checked='checked'<?php endif; ?>/>&nbsp;女
                    </p>
                    <p>
                        <label for=""><span class='red'>*</span>所在地：</label>
                        <select name="province" id="">
                            <option value="">请选择</option>
                        </select>&nbsp;&nbsp;&nbsp;&nbsp;
                        <select name="city">
                            <option value="">请选择</option>
                        </select>
                    </p>
                    <p>
                        <label for="">星座：</label>
                        <select name="night" id="">
                            <option value="">请选择</option>
                            <option value="白羊座">白羊座</option>
                            <option value="金牛座">金牛座</option>
                            <option value="双子座">双子座</option>
                            <option value="巨蟹座">巨蟹座</option>
                            <option value="狮子座">狮子座</option>
                            <option value="处女座">处女座</option>
                            <option value="天秤座">天秤座</option>
                            <option value="天蝎座">天蝎座</option>
                            <option value="射手座">射手座</option>
                            <option value="魔羯座">魔羯座</option>
                            <option value="水瓶座">水瓶座</option>
                            <option value="双鱼座">双鱼座</option>
                        </select>
                    </p>
                    <p>
                        <label for="" class='intro'>一句话介绍自己：</label>
                        <textarea name="intro"><?php echo ($user["intro"]); ?></textarea>
                    </p>
                    <p>
                        <input type="submit" value='保存修改' class='edit-sub'/>
                    </p>
                </form>
            </div>
            <div class='form hidden'>
                <form action="<?php echo U('editFace');?>" method='post'>
                    <div class='edit-face'>
                        <img id="preview" src="
                        <?php if($user["face180"]): echo ($user["face180"]); ?>
                        <?php else: ?>
                            /Public/Images/noface.gif<?php endif; ?>" width='180' height='180' id='face-img'/>
                        <p>
                        <!-- 文件上传 -->
                            <input type="file"  id='face'/>
                        </p>
                        <p>
                        <!-- 这三个隐藏域是用来存放头像服务器路径的 -->
                            <input type="hidden" name='face180' value=''/>
                            <input type="hidden" name='face80' value=''/>
                            <input type="hidden" name='face50' value=''/>
                            <input type="submit" value='保存修改' class='edit-sub'/>
                        </p>
                    </div>
                </form>
            </div>
            <div class='form hidden'>
                <form action="<?php echo U('editPwd');?>" method='post' name='editPwd'>
                    <p class='account'>登录邮箱：<span>admin@admin.com</span></p>
                    <p>
                        <label for=""><span class='red'>*</span>旧密码：</label>
                        <input type="password" name='old' class='input'/>
                    </p>
                    <p>
                        <label for=""><span class='red'>*</span>新密码：</label>
                        <input type="password" name='new' class='input' id='new'/>
                    </p>
                    <p>
                        <label for=""><span class='red'>*</span>确认密码：</label>
                        <input type="password" name='newed' class='input'/>
                    </p>
                    <p>
                        <input type="submit" value='确认修改' class='edit-sub'/>
                    </p>
                </form>
            </div>
        </div>
    </div>
<!--==========内容主体结束==========-->
    <script type='text/javascript'>
    //在模板文件中定义的变量会被解析成字符串
    //动态设置js全局变量
    //外部文件都是都是用jquert的$方法进行初始化编
    //程(加载了dom结构)的所以在外部js文件可以找到这些定义的变量
        var address = "<?php echo ($user["location"]); ?>";
        //用户星坐
        var constellation = "<?php echo ($user["constellation"]); ?>";
        //静态资源路径
        var PUBLIC = '/Public';
        var uploadUrl = '<?php echo U("Common/uploadFace");?>'
        ;
        //用户sessionid的值
        //用session_id函数输出到js变量中
        var sid = '<?php echo session_id();?>';
        //把项目在服务器中的中的根路径
        //如本项目在本地服务器的weibo目录下
        //root值则为/weibo
        var ROOT = '';
    </script>
</body>
</html>
<SCRIPT>
    $('#face').change(function(){
        var a = new FormData();
        a.append("image", $("#face")[0].files[0]);
        a.append("id", 1);
        $.ajax({
            url:uploadUrl,
            xhrFields:{
                    withCredentials:true
            },
            type: "POST",
            cache: false,
            data: a,
            processData: false,
            contentType:false,
            async: false,
            dataType:'json',
            success: function (result) {
                $('#preview').attr('src','/'+result.path.max.split('./')[1])
                $('input[name=face180]').val('/'+result.path.max.split('./')[1])
                $('input[name=face80]').val('/'+result.path.mid.split('./')[1])
                $('input[name=face50]').val('/'+result.path.sma.split('./')[1])
            },
            error:function(error){
                console.log(error)
            }
            //cache 上传文件不需要缓存，所以设置false
            //processData 因为data值是FormData对象，不需要对数据处理
            //contentType 因为是由form表单构造的FormData对象，且已声明了属性enctype，所以为false
        })
    })
</SCRIPT>